package com.example.springboot_myproject.Mapper;

import com.example.springboot_myproject.Model.Student;
import com.example.springboot_myproject.Model.StudentFuzzyQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
//    查询所有信息
    @Select("<script> select * from student " +
        "<where>" +
        "<if test='  sname != null  '> and sname like CONCAT('%',#{sname},'%')</if>" +
        "<if test='  sno != null  '> and sno like CONCAT('%',#{sno},'%')</if>" +
        "<if test='  sjob != null  '> and sjob like CONCAT('%',#{sjob},'%')" +
        "</if></where></script>")
    List<Student> selectFuzzytianming(StudentFuzzyQuery studentFuzzyQuery , @Param("sname") String sname,
                                  @Param("sno") String sno, @Param("sjob") String sjob);

//     添加用户信息
    @Insert("INSERT INTO student(sno,sname,sjob,stel,sdid) VALUES (#{sno},#{sname},#{sjob},#{stel},#{sdid})")
    int insertStudent(Student student);
    @Select("select * from student where sno = #{sno}")
    public List<Map<String,Object>> selectStudentBySno(Student student);

//    修改用户信息
    @Update("update student set sno = #{sno}, sname = #{sname}, sjob = #{sjob}, stel = #{stel},sdid = #{sdid} where sid = #{sid}")
    public Integer UpdateStudent(Student student);

//    删除用户
    @Delete("delete from student where sid =#{sid}")
    public void DeleteById(String ids);
}
